package main.sort;

import java.util.Arrays;

public abstract class BaseSort {
    protected int[] array;
    public String name;

    public BaseSort(int[] array) {
        this.array = array;
    }

    public abstract void sort();

    public void swap(int[] array, int i, int j) {
        int temp = array[i];
        array[i] = array[j];
        array[j] = temp;
    }

    public int getMax() {
        return getMax(0, array.length - 1);
    }

    public int getMin() {
        return getMin(0, array.length - 1);
    }

    public int getMax(int l, int r) {
        int max = array[l];
        for (int i = l + 1; i <= r; i++) {
            if (array[i] > max) {
                max = array[i];
            }
        }
        return max;
    }

    public int getMin(int l, int r) {
        int min = array[l];
        for (int i = l + 1; i <= r; i++) {
            if (array[i] < min) {
                min = array[i];
            }
        }
        return min;
    }

    public void print() {
        System.err.println(Arrays.toString(array));
    }

    public int[] getArray() {
        return array;
    }

    public void setArray(int[] array) {
        this.array = array;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
